/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package repstream.View;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import repstream.Observer.Observer;
import repstream.controler.Controler;
import repstream.model.Model;

/**
 *
 * @author bu2spencer
 */
public class Frame extends JFrame implements Observer{
    private Controler controler;
    private BarMenu barMenu;
    private JPanel playerVolume;
    private JPanel playerBouton;
    private JPanel playerAfficheur;
    private JPanel playerControle;
    private JLabel lbVolume;
    private JLabel sVolume;
    private JButton bPlay = null;
    private JButton bPause = null;
    private JButton bStop = null;
    private JSlider sSlider;
    private JTextField fldAffichageDuree;
    private JTextField fldAffichagePosition;
    private UrlFrame urlFrame;

    public Frame(Controler controler) {
        this.controler = controler;
        this.setVisible(true);
        this.setLocationRelativeTo(null);
        this.setPreferredSize(new Dimension(1150,650));
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setTitle("RepStream");
        this.setLayout(new BorderLayout());
        barMenu = new BarMenu(this);
        this.setJMenuBar(barMenu);
        urlFrame = new UrlFrame(controler);
        
        
        // Panel regroupant les informations pour le volume 

            playerVolume = new JPanel();
            lbVolume = new JLabel("Volume");
            playerVolume.add(lbVolume);
            //playerVolume.add(sVolume);

            // Panel regroupant les boutons 

            playerBouton = new JPanel(new FlowLayout());
            
            bPlay = new JButton("Play");
            playerBouton.add(bPlay);
            /*bPlay.addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            player.start();
                            // FAIRE QUE LE THREAD CONTINUE 
                        }
                    });
            */
            
            bPause = new JButton("Pause");
            playerBouton.add(bPause);
            
            
            bStop = new JButton("Stop");
            playerBouton.add(bStop);

            // Panel regroupant les afficheurs 

            playerAfficheur = new JPanel(new BorderLayout());
            fldAffichageDuree = new JTextField();
            fldAffichagePosition = new JTextField();
            playerAfficheur.add(fldAffichageDuree, BorderLayout.NORTH);
            playerAfficheur.add(fldAffichagePosition, BorderLayout.CENTER);
            playerAfficheur.add(playerVolume, BorderLayout.SOUTH);

            // Panel regroupant la barre de progression, les boutons et l'afficheur 

            playerControle = new JPanel(new BorderLayout());
            //playerControle.add(sSlider, BorderLayout.NORTH);
            //playerControle.add(playerAfficheur, BorderLayout.CENTER);
            //playerControle.add(playerBouton, BorderLayout.SOUTH);
        
        this.add(playerVolume);
        this.add(playerBouton);
        this.add(playerAfficheur);
        this.add(playerControle);
        
        
        validate();
        System.out.println("Frame created");
    }


    @Override
    public void update(Model clientStreaming) {
       this.removeAll();
        
        validate();
    }

    public UrlFrame getUrlFrame() { return urlFrame; } ;

    
}
